﻿using System.Buffers;
using System.Net.Security;
using System.Text;
using Letter.IO.Binary;
using Letter.Net.SSL;
using Letter.Net.Tcp;

namespace ssl_connection;

public class SslConnection : ADefaultFixedHeaderBytesConnection
{
    public static string serverAddr = "127.0.0.1:20001";

    public SslConnection(BinaryOrder order) : base(order)
    {
        
    }

    public SslConnection(BinaryOrder order, SSLOptions sslOptions, Func<Stream, SslStream> sslStreamFactory)
        : base(order, sslOptions, sslStreamFactory)
    {
        
    }

    protected override void OnMessage(ReadOnlySequence<byte> buf)
    {
        var str = System.Text.Encoding.UTF8.GetString(buf);
        Console.WriteLine(str);
    }

    public override void OnInactive()
    {
        Console.WriteLine("关闭连接--开始");
        base.OnInactive();
        Console.WriteLine("关闭连接--结束");
    }
}